import java.util.Scanner;

public class LoanCalculator {

    public static double calculateEqualPrincipalInterest(double a, int m, double i) {
        return ((m + 1) * a * i) / 2;
    }

    public static double calculateEqualInstallmentInterest(double a, int m, double i) {
        return (m * a * i * Math.pow((1 + i), m)) / (Math.pow((1 + i), m) - 1) - a;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入贷款总额（万元）：");
        double a = scanner.nextDouble();

        System.out.print("请输入贷款时间（个月）：");
        int m = scanner.nextInt();

        System.out.print("请输入年利率（例如5%请输入5，直接输入数字）：");
        double annualInterestRate = scanner.nextDouble();

        double monthlyInterestRate = (annualInterestRate / 100) / 12;
        double equalPrincipalInterest = calculateEqualPrincipalInterest(a, m, monthlyInterestRate);
        double equalInstallmentInterest = calculateEqualInstallmentInterest(a, m, monthlyInterestRate);

        System.out.printf("等额本金还款法的总利息为：%.2f 万元%n", equalPrincipalInterest);
        System.out.printf("等额本息还款法的总利息为：%.2f 万元%n", equalInstallmentInterest);

        scanner.close();
    }
}